import javax.swing.*;
import java.util.Random;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        //输出乘法口诀
        int a=1;
        int b=1;
        for (a=1;a<10;a++){
            for (b=1;b<a+1;b++){
                System.out.print(b+"*"+a+"="+a*b+"\t");
            }
            System.out.println();
        }
    }
    public static void main11(String[] args) {
        //根据年龄，来打印出当前年龄的人是少年（<18),青年（18-28），中年（29-55），老年（>56）
        Random i = new Random();//随机生成一个数字年龄
        int age = i.nextInt(120);//年龄范围
        Scanner in = new Scanner(System.in);
        while (true) {
            System.out.println("请输入你的年龄");
            int yourage = in.nextInt();
            if (yourage < 10) {
                System.out.println("你是少年");
            } else if (18 < yourage || yourage < 28) {
                System.out.println("你是青年");
            } else if (29 < yourage || yourage < 55) {
                System.out.println("你是中年");
            } else if (yourage > 56) {
                System.out.println("你是老年");
            }
            break;
        }
    }

    public static void main10(String[] args) {
        //猜数字游戏
        Random r = new Random();//实例化一个random类，生成随机数
        int num = r.nextInt(101);//生成一个随机数字范围[0,101)
        Scanner in = new Scanner(System.in);
        while (true) {
            System.out.println("请输入你猜的数字");
            int guess = in.nextInt();
            if (guess > num) {
                System.out.println("猜大了！");
            } else if (guess == num) {
                System.out.println("猜对了！");
                break;
            } else if (guess < num) {
                System.out.println("猜小了");
            }
        }

    }

    public static void main9(String[] args) {
        //使用for循环计算1！+2！+3！+4！+5！
        int i = 1;
        int sum = 0;
        while (i <= 5) {
            int a = 1;
            int b = 1;
            for (a = 1; a <= i; a++) {
                b *= a;
            }
            sum += b;
            i++;
        }
        System.out.println(sum);
    }

    public static void main8(String[] args) {
        //使用for循环写出5的阶乘
        int a = 1;
        int b = 1;
        for (a = 1; a <= 5; a++) {
            b *= a;
        }
        System.out.println(b);
    }

    public static void main7(String[] args) {
        //计算1！+2！+3！+4！+5！
        int i = 1;
        int sum = 0;
        while (i <= 5) {
            int a = 1;
            int num = 1;
            while (a <= i) {
                num *= a;
                a++;
            }
            sum += num;
            i++;
        }
        System.out.println(sum);
    }

    public static void main6(String[] args) {
        //计算五的阶乘
        int a = 1;
        int num = 1;
        while (a <= 5) {
            num *= a;
            a++;
        }
        System.out.println(num);
    }

    public static void main5(String[] args) {
        //找到1-100之间，既能被三整除，也能被五整除的数据
        //使用break或者continue
        int a = 1;
        while (a <= 100) {
            if (a % 15 != 0) {
                a++;
                continue;
            }
            System.out.println(a);
            a++;
        }
    }

    public static void main4(String[] args) {
        int a = 1;
        int num = 0;
        while (a <= 100) {
            num += a;
            a++;
        }
        System.out.println(num);
    }

    public static void main3(String[] args) {
        int a = 1;
        while (a <= 10) {
            System.out.println(a);
            a++;
        }
    }

    public static void main2(String[] args) {
        int year = 2000;
        if (year % 400 == 0) {
            System.out.println("世纪闰年");
        }
        int year2 = 2024;
        if (year2 % 4 == 0 || year2 % 100 != 0) {
            System.out.println("普通闰年");
        } else {
            System.out.println("hahah");
        }
    }

    public static void main1(String[] args) {
        int a = 10;
        if (a % 2 == 0) {
            System.out.println("a是偶数");
        } else System.out.println("a是奇数");
    }
}
